func solve(board [][]byte) {
	if len(board) == 0 || len(board[0]) == 0 {
		return
	}
	m, n := len(board), len(board[0])
	//遍历所有的行，把第0列和第n-1列dfs一遍
	for i := 0; i < m; i++ {
		dfs(board, i, 0, m, n)
		dfs(board, i, n-1, m, n)
	}
	//遍历所有的列，把第0行和第n-1行dfs一遍
	for j := 1; j < n; j++ {
		dfs(board, 0, j, m, n)
		dfs(board, m-1, j, m, n)
	}

	//最后全部遍历一遍遇到Y则为O，否则是X,遍历时间复杂度为O(m*n)
	for i := 0; i < m; i++ {
		for j := 0; j < n; j++ {
			if board[i][j] == 'Y' {
				board[i][j] = 'O'
			} else {
				board[i][j] = 'X'
			}
		}
	}
}

//从边界出发，碰到O则标记为Y，然后dfs其周围的点,dfs过程中每个点至多标记一次,时间复杂度O(m*n)
func dfs(board [][]byte, x, y int, m, n int) {
	if x < 0 || x >= m || y < 0 || y >= n || board[x][y] != 'O' {
		return
	}
	board[x][y] = 'Y'
	dfs(board, x+1, y, m, n)
	dfs(board, x-1, y, m, n)
	dfs(board, x, y+1, m, n)
	dfs(board, x, y-1, m, n)
}
